package sy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * SysBuilding entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sys_building", catalog = "ssh")
public class SysBuilding implements java.io.Serializable {

	// Fields
	
	private String id;
	private SysProject sysProject;
	private String name;
	private String code;	
	private String latitude;
	private String longitude;
	
	@JsonProperty(value = "projectName")
    private String projectName;

	// Constructors

	/** default constructor */
	public SysBuilding() {
	}

	/** full constructor */
	public SysBuilding(SysProject sysProject, String name, String code,
			String latitude,String longitude) {
		this.sysProject = sysProject;
		this.name = name;
		this.code = code;
		this.latitude = latitude;
		this.longitude = longitude;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.string")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 64)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "sysProject")
	public SysProject getSysProject() {
		return this.sysProject;
	}

	public void setSysProject(SysProject sysProject) {
		this.sysProject = sysProject;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "code")
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "latitude")
	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	@Column(name = "longitude")
	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	
	@Transient
    public String getProjectName() {
		if(getSysProject()==null){
			return "";
		}
    	return getSysProject().getName();
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}
	
}